//////////Change the directory before running the code
////////// Panel A
cd "D:\data&code"
*quietly {

	// Load dataset
	use pseudo_dataset/edgar_a, clear

	// Interaction
	gen INTER = event_window*pass_family
	label variable INTER			"Passive family x Around contest"

	// Regressions
	areg view_d pass_family agg_ownershipw if event_window==1, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7a, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes replace

	areg view_d pass_family agg_ownershipw if event_window==0, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7a, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw if event_window==0 & year2event<=0, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7a, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw if event_window==0 & year2event>=0, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7a, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw INTER event_window, ab(fund_family_id) vce(cluster gvkey)
	outreg2 using table_7a, keep(pass_family agg_ownershipw INTER event_window) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw INTER, ab(meetingid) vce(cluster gvkey)
	outreg2 using table_7a, keep(pass_family agg_ownershipw INTER) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	xi: areg view_d agg_ownershipw INTER i.fund_family_id, ab(meetingid) vce(cluster gvkey)
	outreg2 using table_7a, keep(pass_family agg_ownershipw INTER) sortvar(pass_family) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

*}

sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==1
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==0
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==0 & year2event<=0
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==0 & year2event>=0
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window~=.
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window~=.
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window~=.
// View regression table
use table_7a_dta, clear
rm table_7a.txt
browse





///////// Panel B

quietly {

	// Load dataset
	use pseudo_dataset/edgar_a, clear

	// Keep non-Big Three
	keep if big3 == 0

	// Interaction
	gen INTER = event_window*pass_family
	label variable INTER			"Passive family x Around contest"

	// Regressions
	areg view_d pass_family agg_ownershipw if event_window==1, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7b, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes replace

	areg view_d pass_family agg_ownershipw if event_window==0, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7b, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw if event_window==0 & year2event<=0, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7b, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw if event_window==0 & year2event>=0, ab(meetingid ) vce(cluster gvkey)
	outreg2 using table_7b, keep(pass_family agg_ownershipw) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw INTER event_window, ab(fund_family_id) vce(cluster gvkey)
	outreg2 using table_7b, keep(pass_family agg_ownershipw INTER event_window) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	areg view_d pass_family agg_ownershipw INTER, ab(meetingid) vce(cluster gvkey)
	outreg2 using table_7b, keep(pass_family agg_ownershipw INTER) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

	xi: areg view_d agg_ownershipw INTER i.fund_family_id, ab(meetingid) vce(cluster gvkey)
	outreg2 using table_7b, keep(pass_family agg_ownershipw INTER) sortvar(pass_family) label dta tstat adjr2 bracket bdec(3) tdec(2) nocons nonotes append

}


sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==1
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==0
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==0 & year2event<=0
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window==0 & year2event>=0
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window~=.
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window~=.
sum view_d if pass_family~=. & agg_ownershipw~=. & event_window~=.

// View regression table
use table_7b_dta, clear
rm table_7b.txt
browse
